package cn.xbtop.blog.controller;

import cn.xbtop.blog.exception.BlogException;
import cn.xbtop.blog.utils.Result;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/2/19 17:21
 */
@RestController
@RequestMapping("/test")
public class TestController {
    /**
     * 测试异常
     * @param id
     * @return
     */
    @RequestMapping(value = "/testException/{id}", method = RequestMethod.GET)
    public Result<Object> testException(@PathVariable Integer id) {
        if (id == 1) {
            return new Result<>();
        } else {
            throw new BlogException("发生了异常！");
        }
    }
}
